package com.netposa.datawarehouse.bodysearch;

import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig;
import com.netposa.library.datawarehouse.aggregate.annotation.EnableAggregateConfiguration;
import com.netposa.library.datawarehouse.aggregate.helper.ResourceDefined.ResourceType;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.ApplicationPid;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration;
import org.springframework.boot.system.ApplicationPidFileWriter;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;

@SpringBootApplication(
   scanBasePackages = {"com.netposa"},
   exclude = {SolrAutoConfiguration.class}
)
@MapperScan(
   basePackages = {"com.netposa.datawarehouse.bodysearch.mappers"}
)
@EnableDiscoveryClient
@EnableFeignClients(
   basePackages = {"com.netposa"}
)
@EnableApolloConfig
@EnableAggregateConfiguration(
   type = ResourceType.BODY
)
public class BodySearchApplication {
   private static final Logger log = LoggerFactory.getLogger(BodySearchApplication.class);

   @Bean
   public ApplicationPidFileWriter applicationPidFileWriter() {
      return new ApplicationPidFileWriter();
   }

   public static void main(String[] args) {
      ConfigurableApplicationContext context = SpringApplication.run(BodySearchApplication.class, args);
      log.info("----BodySearchApplication Start PID={}----", (new ApplicationPid()).toString());
      context.registerShutdownHook();
   }
}
